package com.yxq.mdt.app.modules.personal.adapter;

import android.text.TextUtils;

import androidx.annotation.Nullable;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.yxq.mdt.app.R;
import com.yxq.mdt.app.glide.GlideHelper;
import com.yxq.mdt.app.modules.personal.bean.MyRelationBean;

import java.util.List;

/**
 * @author L
 * @time
 * @describe 关注列表
 */
public class RelationConcernListAdapter extends BaseQuickAdapter<MyRelationBean.ListBean, BaseViewHolder> {
    public RelationConcernListAdapter(int layoutResId, @Nullable List<MyRelationBean.ListBean> data) {
        super(layoutResId, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MyRelationBean.ListBean item) {
        helper.setGone(R.id.social_like_is_circle_tv, false);
        helper.setGone(R.id.social_browse_tv, false);
        if (TextUtils.isEmpty(item.getResidence())) {
            helper.setGone(R.id.social_city_tv, false);
        } else {
            helper.setGone(R.id.social_city_tv, true);
            helper.setText(R.id.social_city_tv, item.getResidence());
        }
        if (TextUtils.isEmpty(item.getGeneration())) {
            helper.setGone(R.id.social_like_introduce_tv, false);
        } else {
            helper.setGone(R.id.social_like_introduce_tv, true);
            helper.setText(R.id.social_like_introduce_tv, item.getGeneration());
        }
        if (TextUtils.isEmpty(item.getConstellation())) {
            helper.setGone(R.id.social_constellation_tv, false);
        } else {
            helper.setGone(R.id.social_constellation_tv, true);
            helper.setText(R.id.social_constellation_tv, item.getConstellation());
        }

        if ("1".equals(item.getSex())) {
            helper.setImageResource(R.id.social_like_sex_img, R.mipmap.xb_nan);
        } else {
            helper.setImageResource(R.id.social_like_sex_img, R.mipmap.xb_nv);
        }
        if (TextUtils.isEmpty(item.getGsName())) {
            helper.setGone(R.id.social_like_nike_name, false);
        } else {
            helper.setGone(R.id.social_like_nike_name, true);
            helper.setText(R.id.social_like_nike_name, item.getGsName());
        }
        helper.setText(R.id.social_year_tv, item.getBirthdayShow() == 0 ? item.getAge() + "岁" : "保密");
        GlideHelper.setLoadRoundImage(mContext, item.getHeadimg(), R.mipmap.head_icon, helper.getView(R.id.social_like_img));
        helper.setText(R.id.social_photo_tv, item.getImgNum() == 0 ? "无照片" : item.getImgNum() + "张照片");
        helper.addOnClickListener(R.id.social_attention_tv);
        //当前用户是否关注列表用户0 未关注 1或大于1关注
        if ("0".equals(item.getRelationNum())) {
            helper.setText(R.id.social_attention_tv, "关注");
            helper.setBackgroundRes(R.id.social_attention_tv, R.drawable.real_icon_yellow);
        } else {
            helper.setBackgroundRes(R.id.social_attention_tv, R.drawable.real_icon_gray);
            helper.setText(R.id.social_attention_tv, "取消");
        }
    }

}
